﻿@using Enter.Admin.Utils
@using Enter.Admin.Entities
@inject Microsoft.AspNetCore.Http.IHttpContextAccessor HttpContextAccessor
@inject IFreeSql Fsql
@{
    var session = HttpContextAccessor.HttpContext.Session.Get<Employ>();
    var notices = new List<Notice>();
    var total = 0L;
    if (session != null) notices = Fsql.Select<Notice>().Where(t => t.ToUserId == session.Id && t.Readed == false).Count(out total).Skip(0).Take(5).ToList();
}
<!-- begin #header -->
<div id="header" class="header navbar-default">
    <!-- begin navbar-header -->
    <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed navbar-toggle-left" data-click="sidebar-minify">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <a href="/" class="navbar-brand">
            <b class="mr-1">内部</b> 系统
            <span class="navbar-logo">
                <span class="text-blue">一</span>
                <span class="text-red">言</span>
                <span class="text-orange">律</span>
                <span class="text-blue">师</span>
                <span class="text-green">事</span>
                <span class="text-red">务所</span>
            </span>
        </a>
        <button type="button" class="navbar-toggle" data-click="sidebar-toggled">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
    </div>
    <!-- end navbar-header -->
    <!-- begin header-nav -->
    <ul class="navbar-nav d-flex flex-grow-1">
        <li class="navbar-form flex-grow-1">
            @*<form action="" method="POST" name="search">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder='Try searching "Users Today"' />
                        <button type="submit" class="btn btn-search"><i class="fa fa-search"></i></button>
                    </div>
                </form>*@
        </li>
        <li class="dropdown">
            <a href="#" data-toggle="dropdown" class="dropdown-toggle">
                <i class="fa fa-bell"></i>
                <span class="@(total>0? "label label-danger":"")" id="notice-total" style="background:#ea4335">@(total>0? total.ToString():"")</span>
            </a>
            <div class="dropdown-menu media-list dropdown-menu-right">
                <div class="dropdown-header">消息通知</div>
                @foreach (var notice in notices)
                {
                    <a id="notice-row-@notice.Id" href="javascript:;" onclick="show_notice(@notice.Id)" class="dropdown-item media">
                        <div class="media-left">
                            <i class="fa fa-envelope media-object bg-silver-darker"></i>
                        </div>
                        <div class="media-body">
                            <h6 class="media-heading">
                                @notice.Title
                            </h6>
                            @*<p>@Html.Raw(notice.Note)</p>*@
                            <div class="text-muted f-s-12">@notice.CreateTime.ToString("yyyy-MM-dd")</div>
                        </div>
                    </a>
                }
                <div class="dropdown-footer text-center">
                    <a href="@Url.Action("Index", "Notice")">查看更多</a>
                </div>
            </div>
        </li>
        <li class="dropdown navbar-user">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                <div class="image image-icon bg-black text-grey-darker">
                    <i class="material-icons">person</i>
                </div>
                <span class="d-none d-md-inline">@(session?.TrueName) <b class="caret"></b></span>
            </a>
            <div class="dropdown-menu dropdown-menu-right">
                <a href="@Url.Action("Profile", "Home")" class="dropdown-item">编辑个人资料</a>
                @*<a href="javascript:;" class="dropdown-item"><span class="badge badge-danger pull-right">0</span> Inbox</a>
                    <a href="javascript:;" class="dropdown-item">Calendar</a>
                    <a href="javascript:;" class="dropdown-item">Setting</a>*@
                <div class="dropdown-divider"></div>
                <a href="@Url.Action("Logout", "Login")" class="dropdown-item">退出</a>
            </div>
        </li>
    </ul>
    <!-- end header-nav -->

</div>
<!-- end #header -->
<!-- #modal-dialog -->
<div class="modal fade" id="modal-notice" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content" style="display: inline-block;">
            <div class="modal-header">
                <h4 class="modal-title" id="modal-notice-title">消息查看</h4>
            </div>
            <div class="modal-body">
                <div id="modal-notice-note">

                </div>
            </div>
            <div class="modal-footer">
                <a href="javascript:;" id="modal-notice-button" class="btn btn-primary" data-dismiss="modal">确定</a>
            </div>
        </div>
    </div>
</div>